#include "PathUtil.h"
#include <filesystem>
bool PathUtil::createPathIfNotExist(const std::wstring &path)
{
    try
    {
        return std::filesystem::create_directories(std::filesystem::path(path));
    }
    catch (...)
    {
        return false;
    }
}

std::wstring PathUtil::getExecutablePath()
{
    try
    {
        return std::filesystem::current_path().wstring();
    }
    catch (...)
    {
        return std::wstring();
    }
}

bool PathUtil::fileExists(const std::wstring &file_path)
{
    try
    {
        return std::filesystem::exists(std::filesystem::path(file_path));
    }
    catch (...)
    {
        return false;
    }
}

std::vector<std::wstring> PathUtil::listFilesInDir(const std::wstring &dir_path)
{
    std::vector<std::wstring> files;
    try
    {
        for (const auto &entry : std::filesystem::directory_iterator(std::filesystem::path(dir_path)))
        {
            if (entry.is_regular_file())
            {
                files.push_back(entry.path().wstring());
            }
        }
    }
    catch (...)
    {
        files.clear();
    }
    return files;
}
